home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / lib / partman / init.d / 80autouse_swap < prev    next >
Text File  |  2008-10-29  |  991b  |  43 lines

  1. #!/bin/sh
  2.  
  3. . /lib/partman/lib/base.sh
  4.  
  5. mkdir -p /var/lib/partman/autoused_swap
  6.  
  7. partitions=
  8. for dev in /var/lib/partman/devices/*; do
  9.     [ -d "$dev" ] || continue
  10.  
  11.     # Only run the first time each device is encountered
  12.     devbase="$(basename "$dev")"
  13.     [ ! -f "/var/lib/partman/autoused_swap/$devbase" ] || continue
  14.     >"/var/lib/partman/autoused_swap/$devbase"
  15.  
  16.     cd $dev
  17.     open_dialog PARTITIONS
  18.     while { read_line num id size type fs path name; [ "$id" ]; }; do
  19.         [ -f $id/detected_filesystem ] || continue
  20.         fs=$(cat $id/detected_filesystem)
  21.         if [ "$fs" = linux-swap ]; then
  22.             partitions="$partitions $dev,$id"
  23.         fi
  24.     done
  25.     close_dialog
  26. done
  27.  
  28. for part in $partitions; do
  29.     dev=${part%,*}
  30.     id=${part#*,}
  31.     [ -d $dev/$id ] || continue
  32.     if [ -f $dev/$id/method ]; then
  33.         method="$(cat $dev/$id/method)"
  34.         if [ "$method" ] && [ "$method" != swap ]; then
  35.             # Already used for something else, e.g. RAID
  36.             continue
  37.         fi
  38.     fi
  39.     echo swap >$dev/$id/method
  40.     > $dev/$id/format
  41.     update_partition $dev $id
  42. done
  43.